package com.zhongshengnetwork.rightbe.lang.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.BezierRadarHeader;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.wang.avi.AVLoadingIndicatorView;
import com.zhongshengnetwork.rightbe.Constant.APIKey;
import com.zhongshengnetwork.rightbe.Constant.Constant;
import com.zhongshengnetwork.rightbe.CustomApplication;
import com.zhongshengnetwork.rightbe.R;
import com.zhongshengnetwork.rightbe.common.AppThemeUtils;
import com.zhongshengnetwork.rightbe.common.CircleTransform;
import com.zhongshengnetwork.rightbe.common.CommonUtils;
import com.zhongshengnetwork.rightbe.common.DateUtil;
import com.zhongshengnetwork.rightbe.common.GlideRoundTransform;
import com.zhongshengnetwork.rightbe.common.GsonTools;
import com.zhongshengnetwork.rightbe.common.ScreenUtils;
import com.zhongshengnetwork.rightbe.common.TopBarView;
import com.zhongshengnetwork.rightbe.common.activity.AppBaseActivity;
import com.zhongshengnetwork.rightbe.common.customview.ActionSheetDialog;
import com.zhongshengnetwork.rightbe.common.customview.CustomDialog;
import com.zhongshengnetwork.rightbe.common.expandabletextview.ExpandableTextView;
import com.zhongshengnetwork.rightbe.common.utils.ToastUtil;
import com.zhongshengnetwork.rightbe.gsonmodel.CollectModel;
import com.zhongshengnetwork.rightbe.gsonmodel.CommonModel;
import com.zhongshengnetwork.rightbe.gsonmodel.DryCommentModel;
import com.zhongshengnetwork.rightbe.gsonmodel.LangInfoModel;
import com.zhongshengnetwork.rightbe.gsonmodel.WeiShuContentDetailModel;
import com.zhongshengnetwork.rightbe.gsonmodel.WeiShuInfoDetailModel;
import com.zhongshengnetwork.rightbe.https.HttpCallBack;
import com.zhongshengnetwork.rightbe.https.HttpsUtils;
import com.zhongshengnetwork.rightbe.lang.model.BookmarkModel;
import com.zhongshengnetwork.rightbe.login.LoginActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTContentActivity;
import com.zhongshengnetwork.rightbe.wzt.model.WZTUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BookmarkListActivity extends AppBaseActivity implements TopBarView.onTitleBarClickListener {

    private TopBarView topbar;
    private BookmarkModel bookmarkModel;

    private int pageindex = 0;
    private static final int Records = 20;
    private boolean isHasMore = false;
    private ListView listview;
    private int imgW = 0;
    //加载动画
    private AVLoadingIndicatorView avi;
    private List<CollectModel> list;
    private List<String> moreList;
    private MyAdapter adapter;
    private ImageView no_data_img;
    private RefreshLayout mRefreshLayout;
    private ClipboardManager myClipboard;
    private CollectModel collectModel = null;

    private String dataContent = "";
    private EditText search_edit;
    private Button search_button;

    public void hintKeyBoard() {
        //拿到InputMethodManager
        InputMethodManager imm = (InputMethodManager) BookmarkListActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
        //如果window上view获取焦点 && view不为空
        if (imm.isActive() && BookmarkListActivity.this.getCurrentFocus() != null) {
            //拿到view的token 不为空
            if (BookmarkListActivity.this.getCurrentFocus().getWindowToken() != null) {
                //表示软键盘窗口总是隐藏，除非开始时以SHOW_FORCED显示。
                imm.hideSoftInputFromWindow(BookmarkListActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    }

    private void onClickSearch(View view){
        hintKeyBoard();
        String text = search_edit.getText().toString();
        dataContent = text;
        if (mRefreshLayout != null){
            Log.e("TAG","进来获取数据了刷新界面");
                /*
                @param delayed 开始延时
                @param duration 拖拽动画持续时间
                @param dragRate 拉拽的高度比率（要求 ≥ 1 ）
                */
            mRefreshLayout.autoRefresh(100,300,1f,false);
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bookmark_list);

        bookmarkModel =  (BookmarkModel) getIntent().getSerializableExtra("model");
        topbar = (TopBarView)findViewById(R.id.topbar);
        topbar.getRightView().setVisibility(View.GONE);
        topbar.setClickListener(this);
        topbar.getTitleView().setText(bookmarkModel.getBookmarkName());

        myClipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);

        avi = (AVLoadingIndicatorView)findViewById(R.id.avi);
        no_data_img = (ImageView)findViewById(R.id.no_data_img);
        if (moreList == null){
            moreList = new ArrayList<String>();
        }
        if (list == null){
            list = new ArrayList<CollectModel>();
            int width = ScreenUtils.getScreenWidth(BookmarkListActivity.this);
            float density = ScreenUtils.getScreenDensity(BookmarkListActivity.this);
            imgW = (int) ((width-100*density)/3);
        }

        search_edit = (EditText) findViewById(R.id.search_edit);
        search_edit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                if (i == EditorInfo.IME_ACTION_SEARCH) {
                    String search = search_edit.getText().toString().trim();
                    onClickSearch(textView);
                    return true;
                }
                return false;
            }
        });
        search_button = (Button) findViewById(R.id.search_button);
        search_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickSearch(v);
            }
        });

        listview=(ListView) findViewById(R.id.collect_listview);
        adapter=new MyAdapter();
        listview.setAdapter(adapter);
        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                int index = position;// - 1;
                while (index < 0){//解决部分手机点击第一条不是从1开始的问题
                    index+=1;
                }
                if (list != null && list.size() > 0 && index < list.size()){
                    collectShare(index, false);
                }
            }
        });
        listview.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
                if (i == SCROLL_STATE_FLING ||
                        i == SCROLL_STATE_TOUCH_SCROLL){
                    hintKeyBoard();
                }
            }

            @Override
            public void onScroll(AbsListView absListView, int i, int i1, int i2) {

            }
        });

        mRefreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
        //设置 Header 为 贝塞尔雷达 样式
        mRefreshLayout.setRefreshHeader(new BezierRadarHeader(BookmarkListActivity.this).setEnableHorizontalDrag(true));//BezierRadarHeader
        //设置 Footer 为 球脉冲 样式
        mRefreshLayout.setRefreshFooter(new ClassicsFooter(BookmarkListActivity.this).setSpinnerStyle(SpinnerStyle.FixedBehind));//BallPulseFooter ClassicsFooter
        mRefreshLayout.setPrimaryColors(AppThemeUtils.getInstance().getRefreshBackgroundColor(),AppThemeUtils.getInstance().getRefreshAccessColor());
        mRefreshLayout.setEnableRefresh(true);//启用刷新
        mRefreshLayout.setEnableLoadMore(true);//启用加载
        //刷新
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                //refreshlayout.finishRefresh();
                pageindex = 0;
                getData();
            }
        });
        mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //refreshLayout.finishLoadMore();
                loadMore();
            }
        });

        RelativeLayout collect_layout = (RelativeLayout) findViewById(R.id.langcontent_layout);
        collect_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
        listview.setBackgroundColor(AppThemeUtils.getInstance().getBackgroundColor());
        listview.setDivider(new ColorDrawable(AppThemeUtils.getInstance().getBackgroundColor()));
        listview.setDividerHeight((int)(AppThemeUtils.DividerHeight*ScreenUtils.getScreenDensity(CustomApplication.mContext)));

        search_edit.setHintTextColor(AppThemeUtils.getInstance().getLightTextColor());
        search_edit.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());
        RelativeLayout search_top = (RelativeLayout) findViewById(R.id.search_top);
        search_top.setBackgroundColor(AppThemeUtils.getInstance().getSearchBgColor());
        RelativeLayout search_shape_layout = (RelativeLayout) findViewById(R.id.search_shape_layout);
        search_shape_layout.setBackgroundResource(AppThemeUtils.getInstance().getSearchBackground());


        getData();

    }

    /**
     * 点击了返回导航按钮
     */
    @Override
    public void onBackClick() {
        finish();
        //Toast.makeText(LangDetailActivity.this, "你点击了左侧按钮", Toast.LENGTH_LONG).show();
    }

    /**
     * 点击了右边导航按钮
     */
    @Override
    public void onRightClick() {

    }

    //加载更多
    private void loadMore(){

        hintKeyBoard();
        if (search_edit != null){
            if (search_edit.getText() != null){
                String text = search_edit.getText().toString();
                dataContent = text;
            }else {
                dataContent = "";
            }
        }

        final Map<String,String> map = new HashMap<String, String>();
        map.put("pageIndex",pageindex+"");
        map.put("pageRecord",Records+"");
        map.put("dataId", bookmarkModel.getBookmarkId()+"");
        map.put("token", CustomApplication.loginModel.getToken());
        map.put("dataContent", CommonUtils.formatString(dataContent));
        String url = "bookmark/content/list.do";
        HttpsUtils.miniAppDo(map, url,  new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                //listview.stopLoadMore();
                mRefreshLayout.finishLoadMore();
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    pageindex += 1;
                    List<CollectModel> l = GsonTools.getCollectModel(data);
                    if (l != null && l.size() > 0){
                        if (l.size() >= Records){
                            //listview.setPullLoadEnable(true);
                            mRefreshLayout.setEnableLoadMore(true);
                        }else {
                            //listview.setPullLoadEnable(false);
                            mRefreshLayout.setEnableLoadMore(false);
                        }
                        list.addAll(l);
                    }else {
                        //listview.setPullLoadEnable(false);
                        mRefreshLayout.setEnableLoadMore(false);
                    }
                    adapter.notifyDataSetChanged();
                }else {
                    CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                }
            }

            @Override
            public void onError(String msg) {
                //listview.stopLoadMore();
                mRefreshLayout.finishLoadMore();
            }
        });
    }

    public void getData(){

        hintKeyBoard();
        if (search_edit != null){
            if (search_edit.getText() != null){
                String text = search_edit.getText().toString();
                dataContent = text;
            }else {
                dataContent = "";
            }
        }

        pageindex = 0;
        if (listview == null){
            return;
        }
        if (list == null){
            list = new ArrayList<CollectModel>();
        }
        if (list.size() == 0){
            no_data_img.setVisibility(View.VISIBLE);
        }
        new Thread(){
            @Override
            public void run() {
                super.run();
                final Map<String,String> map = new HashMap<String, String>();
                map.put("pageIndex",pageindex+"");
                map.put("pageRecord",Records+"");
                map.put("dataId", bookmarkModel.getBookmarkId()+"");
                map.put("token", CustomApplication.loginModel.getToken());
                map.put("dataContent", CommonUtils.formatString(dataContent));
                String url = "bookmark/content/list.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","评论内容："+data);
                        final CommonModel commonModel = GsonTools.getCommonModel(data);
                        if (commonModel.getFlag().equals("1")){
                            final List<CollectModel> l = GsonTools.getCollectModel(data);
                            if (BookmarkListActivity.this == null){
                                return;
                            }
                            BookmarkListActivity.this.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    //listview.stopRefresh(true);
                                    mRefreshLayout.finishRefresh();
                                    list.clear();
                                    if (l != null && l.size() > 0){
                                        no_data_img.setVisibility(View.INVISIBLE);
                                        if (l.size() >= Records){
                                            //listview.setPullLoadEnable(true);
                                            mRefreshLayout.setEnableLoadMore(true);
                                        }else {
                                            //listview.setPullLoadEnable(false);
                                            mRefreshLayout.setEnableLoadMore(false);
                                        }
                                        list.addAll(l);
                                    }else {
                                        //listview.setPullLoadEnable(false);
                                        mRefreshLayout.setEnableLoadMore(false);
                                    }
                                    adapter.notifyDataSetChanged();
                                    //listview.smoothScrollToPosition(0);
                                    listview.setSelection(0);
                                    pageindex += 1;
                                }
                            });
                        }else {
                            if (BookmarkListActivity.this == null){
                                return;
                            }
                            BookmarkListActivity.this.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    //listview.stopRefresh(true);
                                    mRefreshLayout.finishRefresh();
                                    CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                                }
                            });
                        }
                    }

                    @Override
                    public void onError(String msg) {
                        if (BookmarkListActivity.this == null){
                            return;
                        }
                        BookmarkListActivity.this.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                //listview.stopRefresh(true);
                                mRefreshLayout.finishRefresh();
                            }
                        });
                    }
                });
            }
        }.start();
    }

    private class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return list.size();
        }


        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override
        public boolean isEnabled(int position) {
            // TODO Auto-generated method stub
            return super.isEnabled(position);
        }

        /**
         * @param position
         * @param convertView
         * @param parent
         * @return
         */
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            //convertView的复用
            if (convertView == null) {
                convertView = View.inflate(BookmarkListActivity.this, R.layout.collect_list_item,null);
            }
            View view=convertView;

            ImageView banner_img = (ImageView) view.findViewById(R.id.banner_img);
            LinearLayout banner_like_layout = (LinearLayout) view.findViewById(R.id.banner_like_layout);
            ImageView banner_like_icon = (ImageView) view.findViewById(R.id.banner_like_icon);
            TextView banner_like_count = (TextView) view.findViewById(R.id.banner_like_count);
            LinearLayout banner_collect_layout = (LinearLayout) view.findViewById(R.id.banner_collect_layout);
            ImageView banner_collect_icon = (ImageView) view.findViewById(R.id.banner_collect_icon);
            TextView banner_collect_count = (TextView) view.findViewById(R.id.banner_collect_count);
            LinearLayout banner_share_layout = (LinearLayout) view.findViewById(R.id.banner_share_layout);
            ImageView banner_share_icon = (ImageView) view.findViewById(R.id.banner_share_icon);
            TextView banner_share_count = (TextView) view.findViewById(R.id.banner_share_count);
            LinearLayout banner_comment_layout = (LinearLayout) view.findViewById(R.id.banner_comment_layout);
            ImageView banner_comment_icon = (ImageView) view.findViewById(R.id.banner_comment_icon);
            TextView banner_comment_count = (TextView) view.findViewById(R.id.banner_comment_count);

            //view= LayoutInflater.from(BookmarkListActivity.this).inflate(R.layout.collect_listview_item, null);
            CollectModel model = list.get(position);
            if (CommonUtils.isEmpty(model.getTitle())){
                model.setTitle("【纯图片】");
            }

            ImageView lang_user_header = (ImageView) view.findViewById(R.id.lang_user_header);
            ImageView privateIcon = (ImageView) view.findViewById(R.id.private_icon);
            if (!CommonUtils.isEmpty(model.getPrivateIcon())){
                privateIcon.setVisibility(View.VISIBLE);
                Glide.with(BookmarkListActivity.this).load(model.getPrivateIcon()).transform(new CircleTransform(BookmarkListActivity.this)).dontAnimate().into(privateIcon);
            }else {
                privateIcon.setVisibility(View.GONE);
            }

            ImageView lang_member_icon = (ImageView) view.findViewById(R.id.lang_member_icon);
            if (!CommonUtils.isEmpty(model.getMemberIcon())){
                lang_member_icon.setVisibility(View.VISIBLE);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getMemberIcon()).
                            diskCacheStrategy(DiskCacheStrategy.RESOURCE).fitCenter().centerCrop().into(lang_member_icon);
                }catch (Exception e){
                    LangPublishActivity.uploadError("每日推荐加载图片报错："+e.getLocalizedMessage());
                }

            }else {
                lang_member_icon.setVisibility(View.INVISIBLE);
            }

            FrameLayout lang_user_header_layout = (FrameLayout) view.findViewById(R.id.lang_user_header_layout);
            lang_user_header_layout.setTag(position);
            lang_user_header_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    commentUser((int)v.getTag());
                }
            });
            TextView lang_user_nickname = (TextView) view.findViewById(R.id.lang_user_nickname);
            lang_user_nickname.setTag(position);
            lang_user_nickname.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    commentUser((int)v.getTag());
                }
            });
            TextView lang_time = (TextView) view.findViewById(R.id.lang_time);


            RelativeLayout collect_listview_item_more = (RelativeLayout) view.findViewById(R.id.collect_listview_item_more);
            collect_listview_item_more.setClickable(true);
            collect_listview_item_more.setTag(position);
            collect_listview_item_more.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    commentMore((int)v.getTag());
                }
            });

            ExpandableTextView lang_content = (ExpandableTextView)view.findViewById(R.id.lang_content);
            Glide.with(BookmarkListActivity.this).load(model.getHeader()).transform(new CircleTransform(BookmarkListActivity.this)).dontAnimate().into(lang_user_header);
            lang_user_nickname.setText(model.getNickname());

            //最新全部展示时间
            String s1 = model.getTypename();
            String s2 = "  ·  "+ DateUtil.getChatDate(Long.valueOf(model.getCollecttime())*1000)+"";
            lang_time.setText(s1);
            //lang_time.setText(s1+s2);
            lang_time.setTag(position);
            lang_time.setFocusable(false);

            lang_content.setText(model.getTitle(),position);
            lang_content.setOnExpandStateChangeListener(new ExpandableTextView.OnExpandStateChangeListener() {
                @Override
                public void onExpandStateChanged(TextView textView, boolean isExpanded) {

                }

                @Override
                public void onClickContentText(int position) {
                    collectShare(position, false);
                }

                @Override
                public void onLongPressContentText(int position) {
                    if (list == null || list.size() == 0){
                        return;
                    }
                    if (position >= list.size()){
                        return;
                    }
                    if (list == null || list.size() == 0){
                        return;
                    }
                    final CollectModel model = list.get(position);
                    CommonUtils.copy(BookmarkListActivity.this, model.getTitle(), model.isOriginal(), model.getSourceid());
                }

                @Override
                public void onDoubleContentText(int position) {
                    onClickLike(position);
                }

            });


            //设置主题下的颜色
            RelativeLayout lang_item_layout = (RelativeLayout) view.findViewById(R.id.lang_item_layout);
            lang_item_layout.setBackgroundColor(AppThemeUtils.getInstance().getMainColor());
            lang_user_nickname.setTextColor(AppThemeUtils.getInstance().getUserNameColorOfWeiJu());
            lang_content.mTvContent.setTextColor(AppThemeUtils.getInstance().getTextColorOfWeiJu());

            LinearLayout lang_op_layout = (LinearLayout)view.findViewById(R.id.lang_op_layout);
            Button lang_op1 = (Button) view.findViewById(R.id.lang_op1);
            lang_op1.setTag(position);
            lang_op_layout.setVisibility(View.GONE);
            lang_op1.setVisibility(View.GONE);

            LinearLayout up_img_layout = (LinearLayout) view.findViewById(R.id.up_img_layout);
            ImageView up_img_1 = (ImageView) view.findViewById(R.id.up_img_1);
            FrameLayout up_img_1_layout = (FrameLayout) view.findViewById(R.id.up_img_1_layout);
            ImageView up_img_2 = (ImageView) view.findViewById(R.id.up_img_2);
            FrameLayout up_img_2_layout = (FrameLayout) view.findViewById(R.id.up_img_2_layout);
            ImageView up_img_3 = (ImageView) view.findViewById(R.id.up_img_3);
            FrameLayout up_img_3_layout = (FrameLayout) view.findViewById(R.id.up_img_3_layout);


            LinearLayout middle_img_layout = (LinearLayout) view.findViewById(R.id.middle_img_layout);
            ImageView middle_img_1 = (ImageView) view.findViewById(R.id.middle_img_1);
            FrameLayout middle_img_1_layout = (FrameLayout) view.findViewById(R.id.middle_img_1_layout);
            ImageView middle_img_2 = (ImageView) view.findViewById(R.id.middle_img_2);
            FrameLayout middle_img_2_layout = (FrameLayout) view.findViewById(R.id.middle_img_2_layout);
            ImageView middle_img_3 = (ImageView) view.findViewById(R.id.middle_img_3);
            FrameLayout middle_img_3_layout = (FrameLayout) view.findViewById(R.id.middle_img_3_layout);

            LinearLayout down_img_layout = (LinearLayout) view.findViewById(R.id.down_img_layout);
            ImageView down_img_1 = (ImageView) view.findViewById(R.id.down_img_1);
            FrameLayout down_img_1_layout = (FrameLayout) view.findViewById(R.id.down_img_1_layout);
            ImageView down_img_2 = (ImageView) view.findViewById(R.id.down_img_2);
            FrameLayout down_img_2_layout = (FrameLayout) view.findViewById(R.id.down_img_2_layout);
            ImageView down_img_3 = (ImageView) view.findViewById(R.id.down_img_3);
            FrameLayout down_img_3_layout = (FrameLayout) view.findViewById(R.id.down_img_3_layout);

            up_img_layout.setVisibility(View.GONE);
            middle_img_layout.setVisibility(View.GONE);
            down_img_layout.setVisibility(View.GONE);
            if (model.getImglist() == null){

            }else if (model.getImglist().size() == 1){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);

                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                //Glide.with(BookmarkListActivity.this).load("https://image.daydayrise.net/clerk_h2.gif").into(up_img_1);
                up_img_2_layout.setVisibility(View.INVISIBLE);
                up_img_2.setVisibility(View.INVISIBLE);
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                up_img_3.setVisibility(View.INVISIBLE);
                up_img_3_layout.setVisibility(View.INVISIBLE);
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);

            }else if (model.getImglist().size() == 2){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                up_img_3.setVisibility(View.INVISIBLE);
                up_img_3_layout.setVisibility(View.INVISIBLE);

            }else if (model.getImglist().size() == 3){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


            }else if (model.getImglist().size() == 4){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_2.setVisibility(View.INVISIBLE);
                middle_img_2_layout.setVisibility(View.INVISIBLE);
                middle_img_3.setVisibility(View.INVISIBLE);
                middle_img_3_layout.setVisibility(View.INVISIBLE);

            }else if (model.getImglist().size() == 5){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_3.setVisibility(View.INVISIBLE);
                middle_img_3_layout.setVisibility(View.INVISIBLE);

            }else if (model.getImglist().size() == 6){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


            }else if (model.getImglist().size() == 7){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                down_img_layout.setVisibility(View.VISIBLE);
                down_img_1.setVisibility(View.VISIBLE);
                down_img_1_layout.setVisibility(View.VISIBLE);
                down_img_1_layout.setTag(position+",7");
                down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(6)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                down_img_2.setVisibility(View.INVISIBLE);
                down_img_2_layout.setVisibility(View.INVISIBLE);
                down_img_3.setVisibility(View.INVISIBLE);
                down_img_3_layout.setVisibility(View.INVISIBLE);
            }else if (model.getImglist().size() == 8){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                down_img_layout.setVisibility(View.VISIBLE);
                down_img_1.setVisibility(View.VISIBLE);
                down_img_1_layout.setVisibility(View.VISIBLE);
                down_img_1_layout.setTag(position+",7");
                down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(6)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                down_img_2.setVisibility(View.VISIBLE);
                down_img_2_layout.setVisibility(View.VISIBLE);
                down_img_2_layout.setTag(position+",8");
                down_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(7)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                down_img_3.setVisibility(View.INVISIBLE);
                down_img_3_layout.setVisibility(View.INVISIBLE);
            }else if (model.getImglist().size() == 9){
                up_img_layout.setVisibility(View.VISIBLE);
                up_img_1.setVisibility(View.VISIBLE);
                up_img_1_layout.setVisibility(View.VISIBLE);
                up_img_1_layout.setTag(position+",1");
                up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                ViewGroup.LayoutParams params = up_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(0)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_2.setVisibility(View.VISIBLE);
                up_img_2_layout.setVisibility(View.VISIBLE);
                up_img_2_layout.setTag(position+",2");
                up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(1)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                up_img_3.setVisibility(View.VISIBLE);
                up_img_3_layout.setVisibility(View.VISIBLE);
                up_img_3_layout.setTag(position+",3");
                up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = up_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                up_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(2)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(up_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                middle_img_layout.setVisibility(View.VISIBLE);
                middle_img_1.setVisibility(View.VISIBLE);
                middle_img_1_layout.setVisibility(View.VISIBLE);
                middle_img_1_layout.setTag(position+",4");
                middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(3)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_2.setVisibility(View.VISIBLE);
                middle_img_2_layout.setVisibility(View.VISIBLE);
                middle_img_2_layout.setTag(position+",5");
                middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(4)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                middle_img_3.setVisibility(View.VISIBLE);
                middle_img_3_layout.setVisibility(View.VISIBLE);
                middle_img_3_layout.setTag(position+",6");
                middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = middle_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                middle_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(5)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(middle_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }


                down_img_layout.setVisibility(View.VISIBLE);
                down_img_1.setVisibility(View.VISIBLE);
                down_img_1_layout.setVisibility(View.VISIBLE);
                down_img_1_layout.setTag(position+",7");
                down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_1.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_1.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(6)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_1);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                down_img_2.setVisibility(View.VISIBLE);
                down_img_2_layout.setVisibility(View.VISIBLE);
                down_img_2_layout.setTag(position+",8");
                down_img_2_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_2.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_2.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(7)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_2);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

                down_img_3.setVisibility(View.VISIBLE);
                down_img_3_layout.setVisibility(View.VISIBLE);
                down_img_3_layout.setTag(position+",9");
                down_img_3_layout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Log.e("TAG","点击了图片:"+v.getTag());
                        onClickImageView(v);
                    }
                });
                params = down_img_3.getLayoutParams();
                params.width =imgW;
                params.height = imgW;
                down_img_3.setLayoutParams(params);
                try{
                    Glide.with(BookmarkListActivity.this).load(model.getImglist().get(8)).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(down_img_3);
                }catch (Exception e){
                    LangPublishActivity.uploadError("收藏夹加载图片报错："+e.getLocalizedMessage());
                }

            }

            if (model.getCommentcount() == 0){
                if (model.getType() == 0 || model.getType() == 3 || (!CommonUtils.isEmpty(model.getTypename()) && model.getTypename().contains("评论"))){
                    //评论类型
                    banner_comment_count.setText("回复");
                }else {
                    banner_comment_count.setText("评论");
                }
            }else {
                banner_comment_count.setText(""+model.getCommentcount());
            }
            banner_comment_layout.setTag(position);
            banner_comment_layout.setClickable(true);
            banner_comment_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    collectShare((int)v.getTag(), false);
                }
            });

            //点赞
            if (model.getLikecount() == 0){
                banner_like_count.setText("笔芯");
            }else {
                banner_like_count.setText(""+model.getLikecount());
            }
            if (model.isLiked() == true){
                banner_like_icon.setImageResource(R.drawable.my_like_select);
                banner_like_count.setTextColor(ContextCompat.getColor(BookmarkListActivity.this,R.color.lightGreenColor));
            }else {
                banner_like_icon.setImageResource(R.drawable.my_like);
                banner_like_count.setTextColor(ContextCompat.getColor(BookmarkListActivity.this,R.color.defaultSmallFontColor));
            }
            banner_like_layout.setTag(position);
            banner_like_layout.setClickable(true);
            banner_like_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onClickLike((int)v.getTag());
                }
            });

            if (CommonUtils.isLogin() == true && bookmarkModel.getUserid().equals(CustomApplication.loginModel.getUid())){
                //收藏夹的作者显示删除
                banner_collect_icon.setImageResource(R.drawable.my_delete);
                banner_collect_count.setText("删除");
            }else {
                if (model.getCollectcount() == 0){
                    banner_collect_count.setText("收藏");
                }else {
                    banner_collect_count.setText(""+model.getCollectcount());
                }
                if (model.isCollected() == true){
                    banner_collect_icon.setImageResource(R.drawable.my_collect_select);
                    banner_collect_count.setTextColor(ContextCompat.getColor(BookmarkListActivity.this,R.color.lightGreenColor));
                }else {
                    banner_collect_icon.setImageResource(R.drawable.my_collection);
                    banner_collect_count.setTextColor(ContextCompat.getColor(BookmarkListActivity.this,R.color.defaultSmallFontColor));
                }
            }

            banner_collect_layout.setTag(position);
            banner_collect_layout.setClickable(true);
            banner_collect_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onClickCollect((int)v.getTag());
                }
            });


            banner_share_count.setText(""+model.getSharecount());
            if (!CommonUtils.isEmpty(model.getTypename()) && model.getTypename().contains("评论")){
                banner_share_icon.setImageResource(R.drawable.my_details);
                banner_share_count.setText("详情");
            }else {
                banner_share_icon.setImageResource(R.drawable.my_share);
                if (model.getSharecount() == 0){
                    banner_share_count.setText("分享");
                }
            }

            banner_share_layout.setTag(position);
            banner_share_layout.setClickable(true);
            banner_share_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    collectShare((int)v.getTag(), true);
                }
            });

            return view;
        }
    }

    private void onClickCopy(final int index, boolean isShare){
        if (list == null || list.size() == 0){
            return;
        }

        if(CommonUtils.isLogin() == false){
            Intent intent = new Intent(BookmarkListActivity.this, LoginActivity.class);
            startActivity(intent);
            return;
        }

        final CollectModel model = list.get(index);
        if (CommonUtils.isEmpty(model.getTitle())){
            return;
        }
        try{
            ClipData myClip = ClipData.newPlainText("text", model.getTitle());
            myClipboard.setPrimaryClip(myClip);
            if (isShare == true){
                Toast.makeText(BookmarkListActivity.this, "文字已复制，分享启动中...",
                        Toast.LENGTH_SHORT).show();
            }else{
                Toast.makeText(BookmarkListActivity.this, "文字已复制~",
                        Toast.LENGTH_SHORT).show();
            }
        }catch (Exception e){

        }
    }

    //进入微句详情
    private void dealWithLang(String langid){
        avi.show();
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, langid);
        map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
        String url = "miniapp/langappid/getlanginfo.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                avi.hide();
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    LangInfoModel langInfoModel = GsonTools.getLangInfoModel(data);

                    //langInfoModel.setUserid(CustomApplication.loginModel.getUid());
                    //langInfoModel.setHeader(CustomApplication.loginModel.getHeader());
                    //langInfoModel.setNickname(CustomApplication.loginModel.getNickname());
                    //langInfoModel.setIscare(true);
                    if (langInfoModel.getStatus() == 1){
                        Intent intent = new Intent(BookmarkListActivity.this, LangDetailActivity.class);
                        Bundle bundle=new Bundle();
                        bundle.putSerializable("model", langInfoModel);//序列化
                        intent.putExtras(bundle);//发送数据
                        startActivity(intent);
                    }
                }else {
                    CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                }
            }

            @Override
            public void onError(String msg) {
                avi.hide();
            }
        });
    }

    //进入评论详情
    private void dealWithComment(String commentid){
        avi.show();
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, commentid);
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        String url = "miniapp/langappid/commentcontent.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                avi.hide();
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    DryCommentModel model = GsonTools.getCommentModel(data);
                    Intent intent = new Intent(BookmarkListActivity.this,LangCommentActivity.class);
                    intent.putExtra("id",model.getSourceid());
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("DryCommentModel", model);
                    intent.putExtras(bundle);
                    startActivity(intent);
                }else {
                    CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                }
            }

            @Override
            public void onError(String msg) {
                avi.hide();
            }
        });
    }

    //点击了评论用户
    private void commentUser(final int index){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }
        final CollectModel model = list.get(index);
        //进入个人主页
        Intent intent = new Intent(BookmarkListActivity.this, UserLangActivity.class);
        intent.putExtra(APIKey.useridKey,model.getUserid());
        intent.putExtra(APIKey.typeKey,1);
        intent.putExtra(APIKey.titleKey,model.getNickname());
        startActivity(intent);
    }

    //评论点击更多
    private void commentMore(final int index){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }
        final CollectModel model = list.get(index);
        moreList.clear();
        if (model.isdelete() == false){
            if (model.getType() == 0) {//评论
            }else {
                moreList.add("分享");
            }
            if (!CommonUtils.isEmpty(model.getFromSourceId())){
                collectModel = model;
                moreList.add("来源");
            }
            moreList.add("详情");
            moreList.add("复制");
        }
        moreList.add("删除");
        ActionSheetDialog actionSheetDialog = new ActionSheetDialog(BookmarkListActivity.this)
                .builder()
                .setTitle("请选择")
                .setCancelable(false)
                .setCanceledOnTouchOutside(true);
        for (String s : moreList){
            actionSheetDialog.addSheetItem(s, null, new ActionSheetDialog.OnSheetItemClickListener() {
                @Override
                public void onClick(int which) {
                    if (which > 0){
                        String title = moreList.get(which-1);
                        if (title.equals("分享")){
                            collectShare(index, true);
                        }else if (title.equals("详情")){
                            collectShare(index, false);
                        }else if (title.equals("删除")){
                            onClickCollect(index);
                        }else if (title.equals("来源")){
                            fromSource();
                        }else if (title.equals("复制")){
                            if (list == null || list.size() == 0){
                                return;
                            }
                            if(index < 0 || index >= list.size()){
                                return;
                            }
                            final CollectModel model = list.get(index);
                            CommonUtils.copy(BookmarkListActivity.this, model.getTitle(), model.isOriginal(), model.getSourceid());
                        }
                    }
                }
            });
        }
        actionSheetDialog.show();
    }

    //进入分享详情
    private void collectShare(final int index, boolean share){

        hintKeyBoard();

        final CollectModel model = list.get(index);
        if (model.getType() == 0){//评论

            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            String url = "miniapp/langappid/commentcontent.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {

                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        DryCommentModel model = GsonTools.getCommentModel(data);
                        Intent intent = new Intent(BookmarkListActivity.this, LangCommentActivity.class);
                        intent.putExtra("id",model.getSourceid());
                        intent.putExtra("isShare",false);
                        Bundle bundle = new Bundle();
                        bundle.putSerializable("DryCommentModel", model);
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }else {
                        CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                    }
                }

                @Override
                public void onError(String msg) {

                }
            });
        }else if(model.getType() == 1){
            //微句
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
            String url = "miniapp/langappid/getlanginfo.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        LangInfoModel langInfoModel = GsonTools.getLangInfoModel(data);

                        if (langInfoModel.getStatus() == 1){
                            Intent intent = new Intent(BookmarkListActivity.this, LangDetailActivity.class);
                            Bundle bundle=new Bundle();
                            bundle.putSerializable("model", langInfoModel);//序列化
                            intent.putExtras(bundle);//发送数据
                            intent.putExtra("share",share);
                            startActivity(intent);
                        }
                    }else {
                        CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                    }
                }

                @Override
                public void onError(String msg) {

                }
            });
        }else if (model.getType() == 2){
            //微纸条内容
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
            String url = "weishu/content/info.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        WeiShuContentDetailModel langInfoModel = GsonTools.getWeiShuContentDetailModel(data);
                        Intent intent = new Intent(BookmarkListActivity.this, WZTContentActivity.class);
                        Bundle bundle=new Bundle();
                        bundle.putSerializable("model", langInfoModel);//序列化
                        intent.putExtra("share",share);
                        intent.putExtras(bundle);//发送数据
                        startActivity(intent);
                    }else {
                        CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                    }
                }

                @Override
                public void onError(String msg) {
                }
            });
        }else if (model.getType() == 3){
            //微纸条评论
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.idKey, model.getSourceid());
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            String url = "weishu/theme/comment/detail.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    CommonModel commonModel = GsonTools.getCommonModel(data);
                    if (commonModel.getFlag().equals("1")){
                        DryCommentModel model = GsonTools.getCommentModel(data);
                        Intent intent = new Intent(BookmarkListActivity.this, LangCommentActivity.class);
                        intent.putExtra("id",model.getSourceid());
                        intent.putExtra("type",1);
                        Bundle bundle = new Bundle();
                        bundle.putSerializable("DryCommentModel", model);
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }else {
                        CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                    }
                }

                @Override
                public void onError(String msg) {

                }
            });
        }
    }

    private void onClickLike(final int index){

        hintKeyBoard();

        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(BookmarkListActivity.this, LoginActivity.class);
            startActivity(intent);
            return;
        }

        final CollectModel model = list.get(index);
        if (model.isLiked() == true){
            return;
        }
        model.setLikecount(model.getLikecount()+1);
        model.setLiked(true);
        adapter.notifyDataSetChanged();
        if (model.getType() == 0){
            //评论
            final Map<String,String> map = new HashMap<String, String>();
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
            map.put(APIKey.idKey,model.getSourceid());
            String url = "miniapp/"+"langappid"+"/langlikecomment.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                }

                @Override
                public void onError(String msg) {

                }
            });
        }else if (model.getType() == 1){
            //微句
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            map.put("id", model.getSourceid());
            map.put(APIKey.typeKey,"1");
            map.put("answerid","0");
            String url = "miniapp/"+"langappid"+"/langcl.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    Log.e("TAG","笔芯结果："+data);
                    //initLang();
                }

                @Override
                public void onError(String msg) {
                }
            });
        }else if (model.getType() == 2){
            //微纸条内容
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            map.put("id", model.getSourceid());
            String url = "weishu/content/like.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    Log.e("TAG","笔芯结果："+data);
                    //initLang();
                }

                @Override
                public void onError(String msg) {
                }
            });
        }else if (model.getType() == 3){
            //微纸条评论
            final Map<String,String> map = new HashMap<String, String>();
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
            map.put(APIKey.idKey,model.getSourceid());
            String url = "weishu/theme/comment/like.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                }

                @Override
                public void onError(String msg) {

                }
            });
        }
    }

    private void onClickCollect(final int index){

        hintKeyBoard();

        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(BookmarkListActivity.this, LoginActivity.class);
            startActivity(intent);
            return;
        }

        final CollectModel model = list.get(index);
        if (CommonUtils.isLogin() == true && bookmarkModel.getUserid().equals(CustomApplication.loginModel.getUid())){
            //作者删除
            CustomDialog dialog = null;
            final CustomDialog.Builder builder = new CustomDialog.Builder(BookmarkListActivity.this);
            builder.setTitle("温馨提示");
            builder.setMessage("确定要从本收藏夹中删除吗？");
            builder.setPositiveButton("删除", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            final HashMap<String, String> map = new HashMap<String, String>();
                            String url = "bookmark/content/delete.do";
                            map.put(APIKey.tokenKey, CommonUtils.formatString(CustomApplication.loginModel.getToken()));
                            map.put("bookmarkId", "" + bookmarkModel.getBookmarkId()+"");
                            map.put("contentId", "" + model.getId());
                            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                                @Override
                                public void onSuccess(String data) {
                                    CommonModel commonModel = GsonTools.getCommonModel(data);
                                    runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            if (commonModel.getFlag().equals("1")){
                                                ToastUtil.show(BookmarkListActivity.this, "删除成功");
                                                list.remove(model);
                                                adapter.notifyDataSetChanged();
                                            }else {
                                                CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                                            }
                                        }
                                    });
                                }

                                @Override
                                public void onError(String msg) {
                                    ToastUtil.show(BookmarkListActivity.this, "删除失败，请稍后尝试~");
                                }
                            });
                        }
                    }){

                    }.start();
                }
            });
            builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            dialog = builder.create();
            dialog.show();

        }else {
            if (model.isCollected() == true){
                return;
            }
            model.setCollected(true);
            model.setCollectcount(model.getCollectcount()+1);
            adapter.notifyDataSetChanged();
            if (model.getType() == 0){
                //评论
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
                map.put("sourceid", model.getSourceid());
                map.put(APIKey.typeKey,"0");
                String url = "miniapp/"+"langappid"+"/addcollection.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","收藏结果："+data);
                    }

                    @Override
                    public void onError(String msg) {
                    }
                });
            }else if (model.getType() == 1){
                //微句
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
                map.put("sourceid", model.getSourceid());
                map.put(APIKey.typeKey,"1");
                String url = "miniapp/"+"langappid"+"/addcollection.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","收藏结果："+data);
                    }

                    @Override
                    public void onError(String msg) {
                    }
                });
            }else if (model.getType() == 2){
                //微纸条内容
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
                map.put("sourceid", model.getSourceid());
                map.put(APIKey.typeKey,"2");
                String url = "miniapp/"+"langappid"+"/addcollection.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","收藏结果："+data);
                    }

                    @Override
                    public void onError(String msg) {
                    }
                });
            }else if (model.getType() == 3){
                //微纸条评论
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
                map.put("sourceid", model.getSourceid());
                map.put(APIKey.typeKey,"3");
                String url = "miniapp/"+"langappid"+"/addcollection.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","收藏结果："+data);
                    }

                    @Override
                    public void onError(String msg) {
                    }
                });
            }
        }
    }

    //点击图片处理
    private void onClickImageView(final View view){

        hintKeyBoard();

        if (list == null || list.size() == 0){
            return;
        }

        if (BookmarkListActivity.this == null){
            return;
        }

        if (CustomApplication.isWatchingImg == true){
            return;
        }
        CustomApplication.isWatchingImg = true;

        String tag = view.getTag().toString();
        List<String> l = CommonUtils.stringToArrayList(tag);
        CollectModel model = list.get(Integer.valueOf(l.get(0)));
        int position = Integer.valueOf(l.get(1))-1;


        Intent intent = new Intent(BookmarkListActivity.this, SelfImagePreviewActivity.class);
        intent.putExtra("position",position);
        intent.putExtra("isListImg",true);
        intent.putExtra("imgs",model.getImg());
        //View代表方法传入的控件
        int[] viewLocation = new int[2];
        view.getLocationInWindow(viewLocation);
        int viewX = viewLocation[0]; // x 坐标
        int viewY = viewLocation[1]-(int) (20*ScreenUtils.getScreenDensity(CustomApplication.mContext)); // y 坐标，这里当顶部有状态栏时，要减去状态栏的高度
        intent.putExtra("viewX",viewX);
        intent.putExtra("viewY",viewY);
        intent.putExtra("imgW",imgW);
        intent.putExtra("imgH",imgW);
        BookmarkListActivity.this.startActivity(intent);
        BookmarkListActivity.this.overridePendingTransition(0,0);//可以通过参数设置关闭与要显示的动画效果,0表示无效果.

    }

    private void fromSource(){
        if (collectModel != null){
            if (collectModel.getType() == 0){//评论
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.idKey, collectModel.getFromSourceId());
                if (CommonUtils.isLogin() == true){
                    map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
                }
                String url = "miniapp/langappid/getlanginfo.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        avi.hide();
                        CommonModel commonModel = GsonTools.getCommonModel(data);
                        if (commonModel.getFlag().equals("1")){
                            LangInfoModel langInfoModel = GsonTools.getLangInfoModel(data);
                            if (langInfoModel.getStatus() == 1){
                                Intent intent = new Intent(BookmarkListActivity.this, LangDetailActivity.class);
                                Bundle bundle=new Bundle();
                                bundle.putSerializable("model", langInfoModel);//序列化
                                intent.putExtras(bundle);//发送数据
                                intent.putExtra("share",false);
                                startActivity(intent);
                            }
                        }else {
                            CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                        }
                    }

                    @Override
                    public void onError(String msg) {
                        avi.hide();
                    }
                });
            }else if (collectModel.getType() == 2){//微纸条内容
                dealWithWZT(collectModel.getFromSourceId(), 0);
            }else if (collectModel.getType() == 3){//微纸条评论
                if (CommonUtils.isNumber(collectModel.getFromSourceId())){
                    dealWithWZT(collectModel.getFromSourceId(), 1);
                }else {
                    dealWithWZTContent(collectModel.getFromSourceId());
                }
            }
        }
    }

    private void dealWithWZT(String id, final int selectIndex){
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, id);
        if (CommonUtils.isLogin() == true){
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
        }
        String url = "weishu/theme/info.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    WeiShuInfoDetailModel langInfoModel = GsonTools.getWeiShuInfo(data);

                    if (CommonUtils.isLogin() == true && CustomApplication.loginModel.getUid().equals(langInfoModel.getUserid())){
                        Intent intent = new Intent(BookmarkListActivity.this, WZTActivity.class);
                        Bundle bundle=new Bundle();
                        bundle.putSerializable("model", langInfoModel);//序列化
                        intent.putExtras(bundle);//发送数据
                        intent.putExtra("selectIndex",selectIndex);
                        startActivity(intent);
                    }else {
                        WZTUtils.goToWZT(BookmarkListActivity.this,langInfoModel);
                    }
                }else {
                    CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                }
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

    private void dealWithWZTContent(String langid){
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.idKey, langid);
        if (CommonUtils.isLogin() == true){
            map.put(APIKey.tokenKey,CustomApplication.loginModel.getToken());
        }
        String url = "weishu/content/info.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                CommonModel commonModel = GsonTools.getCommonModel(data);
                if (commonModel.getFlag().equals("1")){
                    WeiShuContentDetailModel langInfoModel = GsonTools.getWeiShuContentDetailModel(data);
                    Intent intent = new Intent(BookmarkListActivity.this, WZTContentActivity.class);
                    Bundle bundle=new Bundle();
                    bundle.putSerializable("model", langInfoModel);//序列化
                    intent.putExtras(bundle);//发送数据
                    startActivity(intent);
                }else {
                    CustomApplication.showTip(commonModel, BookmarkListActivity.this);
                }
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

}
